<?php 
 include_once dirname(__FILE__)."/config.php";
 class configuration_envoi_principal{
		 protected $_result;
		 protected $_cnn;
		 protected $_id;
		 protected $_id_mail;
		 protected $_date_envoi;
		 protected $_heur_envoi;
		 protected $_date_limite;
		 protected $_heur_limte;
		 protected $_parametre;
		 protected $_etat_envoi;
		 public function get_name_table(){ return "configuration_envoi";}
		 public function get_name_id(){ return "id";}
		 public function get_name_id_mail(){ return "id_mail";}
		 public function get_name_date_envoi(){ return "date_envoi";}
		 public function get_name_heur_envoi(){ return "heur_envoi";}
		 public function get_name_date_limite(){ return "date_limite";}
		 public function get_name_heur_limte(){ return "heur_limte";}
		 public function get_name_parametre(){ return "parametre";}
		 public function get_name_etat_envoi(){ return "etat_envoi";}
		 public function set_id($parametre){  $this->_id=$parametre;}	
		 public function set_id_mail($parametre){  $this->_id_mail=$parametre;}	
		 public function set_date_envoi($parametre){  $this->_date_envoi=$parametre;}	
		 public function set_heur_envoi($parametre){  $this->_heur_envoi=$parametre;}	
		 public function set_date_limite($parametre){  $this->_date_limite=$parametre;}	
		 public function set_heur_limte($parametre){  $this->_heur_limte=$parametre;}	
		 public function set_parametre($parametre){  $this->_parametre=$parametre;}	
		 public function set_etat_envoi($parametre){  $this->_etat_envoi=$parametre;}	
		 public function get_result(){ return $this->_result;}
		 public function get_id(){ return $this->_id;}
		 public function get_id_mail(){ return $this->_id_mail;}
		 public function get_date_envoi(){ return $this->_date_envoi;}
		 public function get_heur_envoi(){ return $this->_heur_envoi;}
		 public function get_date_limite(){ return $this->_date_limite;}
		 public function get_heur_limte(){ return $this->_heur_limte;}
		 public function get_parametre(){ return $this->_parametre;}
		 public function get_etat_envoi(){ return $this->_etat_envoi;}
public function __construct(){

		 	$this->_cnn=new databaseconnect();

		 }

 public function INSERT()
{

$sql=" INSERT INTO 
 configuration_envoi(
			id_mail,
			date_envoi,
			heur_envoi,
			date_limite,
			heur_limte,
			parametre,
			etat_envoi)
 VALUES(
			'".$this->_id_mail."',
			'".$this->_date_envoi."',
			'".$this->_heur_envoi."',
			'".$this->_date_limite."',
			'".$this->_heur_limte."',
			'".$this->_parametre."',
			'".$this->_etat_envoi."')";

$this->_result=$this->_cnn->query($sql);
 if(!$this->_result){return 'erreur d\'execution de la requette';}else{return 'success';}
}

 public function UPDATE()
{

 $sql="";
if(!empty($this->_id_mail)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
id_mail='".$this->_id_mail."'";
}
if(!empty($this->_date_envoi)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
date_envoi='".$this->_date_envoi."'";
}
if(!empty($this->_heur_envoi)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
heur_envoi='".$this->_heur_envoi."'";
}
if(!empty($this->_date_limite)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
date_limite='".$this->_date_limite."'";
}
if(!empty($this->_heur_limte)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
heur_limte='".$this->_heur_limte."'";
}
if(!empty($this->_parametre)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
parametre='".$this->_parametre."'";
}
if(!empty($this->_etat_envoi)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
etat_envoi='".$this->_etat_envoi."'";
}
$sql="UPDATE 
configuration_envoi SET 
 ".$sql."
								WHERE id ='".$this->_id."'";

$this->_result=$this->_cnn->query($sql);
 if(!$this->_result){return 'erreur d\'execution de la requette';}else{return 'success';}
}

 public function DELETE(){

 $sql="DELETE FROM 
configuration_envoi 
 
									WHERE id ='".$this->_id."'";

$this->_result=$this->_cnn->query($sql);
 if(!$this->_result){return 'erreur d\'execution de la requette';}else{return 'success';}
}

 public function TRANCATE(){

 $sql="DELETE FROM 
configuration_envoi ";

$this->_result=$this->_cnn->query($sql);
 if(!$this->_result){return 'erreur d\'execution de la requette';}else{return 'success';}
}

 public function SELECT($constraint="",$pagination="")
{

$sql=" SELECT 
 		id,
		id_mail,
		date_envoi,
		heur_envoi,
		date_limite,
		heur_limte,
		parametre,
		etat_envoi
 FROM 
 configuration_envoi";
if($constraint){$sql.=" WHERE 1=1 ".$constraint;}if($pagination){$sql.=$pagination;}
$this->_result=$this->_cnn->query($sql);
 if(!$this->_result){return 'erreur d\'execution de la requette';}else{return 'success';}
}
public function fetch_object(){
$row=mysql_fetch_object($this->_result);
 if($this->_result){
 if($row){
		$this->_id=$row->id;
		$this->_id_mail=$row->id_mail;
		$this->_date_envoi=$row->date_envoi;
		$this->_heur_envoi=$row->heur_envoi;
		$this->_date_limite=$row->date_limite;
		$this->_heur_limte=$row->heur_limte;
		$this->_parametre=$row->parametre;
		$this->_etat_envoi=$row->etat_envoi;
		return $row;
		}else{
					return false;
				}

			}else{
				//echo 'Erreur d\'execution de requette de selection';	
			}
			

		}

}
?>